<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>整屏切换效果</title>
    <link rel="stylesheet" href="../css/common.css">
    <style>
        #container{
           width: 100vw;
           height: 100vh;
           overflow: hidden;
        }
        #container>div{
            width: 100vw;
            height: 100vh;
            font-size: 100px;
            text-align: center;
            transition: 1s;
        }
        .one{
            background-color: lightcoral;
        }
        .two{
            background-color: lightgreen;
        }
        .three{
            background-color: lightsalmon;
        }
        .four{
            background-color: lightseagreen;
        }
        .five{
            background-color: lightslategrey;
        }
    </style>
</head>
<body>
    <div id="container">
        <div class="one">one</div>
        <div class="two">two</div>
        <div class="three">three</div>
        <div class="four">four</div>
        <div class="five">five</div>
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <script>

        if(window.onmousewheel===undefined){
            //表示：当前浏览器是火狐浏览器
            window.addEventListener('DOMMouseScroll',function(e){
                let {detail} = e
                //detail<0 表示滚轮往上，detail>0 表示滚轮往下
                move(detail<0)
            })
        }else{
            //表示：当前浏览器是谷歌浏览器
            //onmousewheel是鼠标滚轮事件
            window.onmousewheel = function(e){
                let {wheelDelta} = e
                //wheelDelta>0 表示滚轮往上，wheelDelta<0 表示滚轮往下
                move(wheelDelta>0)
            }
        }

        let i = 0         //i表示翻屏的数量
        let date = null   //定义日期，用于节流操作
        function move(isdown){
            if(new Date()-date>=500){
                if(isdown){
                    //屏幕往下翻
                    if(--i<0) i = 0
                }else{
                    //屏幕往上翻
                    if(++i>4) i = 4
                }
                $('#container div').css('transform',`translateY(-${i*100}vh)`)
                date = new Date()
            }
        }
    </script>
</body>
</html>